home *** CD-ROM | disk | FTP | other *** search
- package classes.game
- {
- import classes.Main;
- import flash.display.*;
- import flash.events.*;
- import flash.media.*;
- import flash.utils.Timer;
- import libs.kjc.*;
-
- [Embed(source="/_assets/assets.swf", symbol="classes.game.Game")]
- public class Game extends MovieClip
- {
-
- internal static var reStart:Function;
-
-
- public var ScoreBox:ScoreBox;
-
- public var MissionBar:MissionBar;
-
- private var lv:int;
-
- private var score:int;
-
- private var cNum:int;
-
- private var addNum:int;
-
- private var spd:Number;
-
- private var tTimer:Timer;
-
- public var Tom:Tom;
-
- private var playOn:Boolean;
-
- private var cTim:int;
-
- private var addTim:int;
-
- private var deleyR:int;
-
- public var bg:MovieClip;
-
- private var timer:Timer;
-
- private var mTim:int;
-
- private var tNum:int;
-
- private var bonusTim:int;
-
- private var spdA:Array;
-
- private var life:int;
-
- private var deley:int;
-
- public function Game()
- {
- super();
- playOn = false;
- this.bg.gotoAndStop(1);
- reStart = gameReady;
- lv = 0;
- score = 0;
- life = 3;
- tNum = 1;
- addNum = 1;
- mTim = 30;
- addTim = 3;
- bonusTim = 2;
- spdA = new Array(1,1,1.2,1.2,1.5,2);
- deley = 3000;
- deleyR = 1500;
- this.ScoreBox.setScore(score);
- gameReady();
- tTimer = new Timer(1000);
- tTimer.addEventListener(TimerEvent.TIMER,addTimFn);
- timer = new Timer(1500,1);
- timer.addEventListener(TimerEvent.TIMER,playGame);
- Panel.tom = this.Tom;
- }
-
- private function gameStart(param1:MovieClip = null) : void
- {
- var _loc2_:int = 0;
- if(param1 != null)
- {
- KJC_general.remove(param1);
- }
- mTim += addTim;
- if(mTim >= 34)
- {
- addTim = -addTim;
- }
- tNum += addNum;
- if(tNum > 8)
- {
- tNum = 8;
- }
- if(lv >= spdA.length)
- {
- _loc2_ = int(spdA.length - 1);
- }
- else
- {
- _loc2_ = lv;
- }
- spd = spdA[_loc2_];
- this.bg.gotoAndStop(1 + lv % 3);
- ++lv;
- this.ScoreBox.setLv(lv);
- gameReStart();
- }
-
- public function keyFn(param1:String) : void
- {
- if(playOn == false)
- {
- return;
- }
- this.Tom.actionTom(param1);
- }
-
- internal function missionSucces(param1:int) : void
- {
- var _loc3_:Photo = null;
- if(playOn == false)
- {
- return;
- }
- Main.playSound(1);
- cTim -= bonusTim;
- var _loc2_:Boolean = this.MissionBar.clearMission(param1);
- if(_loc2_ == true)
- {
- ++cNum;
- Main.playSound(2);
- setScore(1500);
- _loc3_ = new Photo();
- this.addChild(_loc3_);
- _loc3_.y = 180;
- _loc3_.x = this.Tom.x;
- if(cNum == tNum)
- {
- levelUpFn();
- }
- }
- else
- {
- setScore(300);
- }
- }
-
- private function gameReStart(param1:MovieClip = null) : void
- {
- this.Tom.reSetTom();
- cNum = 0;
- cTim = 0;
- this.MissionBar.setMissionBar(tNum);
- this.ScoreBox.setTim(cTim,mTim);
- playOn = true;
- tTimer.reset();
- tTimer.start();
- timer.reset();
- timer.start();
- }
-
- private function gamePause() : void
- {
- playOn = false;
- tTimer.stop();
- timer.stop();
- }
-
- private function playGame(param1:Event) : void
- {
- if(playOn == false)
- {
- return;
- }
- var _loc2_:Panel = new Panel();
- this.addChildAt(_loc2_,3);
- var _loc3_:int = KJC_general.Random(4);
- _loc2_.x = 100 + _loc3_ * 75;
- _loc2_.y = 395;
- var _loc4_:Number = (2 - _loc3_) * 5;
- _loc2_.setPanel(spd,_loc4_);
- timer.removeEventListener(TimerEvent.TIMER,playGame);
- var _loc5_:int = KJC_general.Random(deleyR) + deley;
- timer = new Timer(_loc5_,1);
- timer.addEventListener(TimerEvent.TIMER,playGame);
- timer.start();
- }
-
- internal function setScore(param1:int) : void
- {
- if(playOn == false)
- {
- return;
- }
- score += param1;
- if(score < 0)
- {
- score = 0;
- }
- this.ScoreBox.setScore(score);
- }
-
- internal function gameReady(param1:MovieClip = null, param2:Boolean = true) : void
- {
- if(param1 != null)
- {
- KJC_general.remove(param1);
- }
- Main.setStageFocus();
- var _loc3_:StartMc = new StartMc();
- this.addChild(_loc3_);
- if(param2 == true)
- {
- KJC_enterframe.moveToFrame(_loc3_,_loc3_.totalFrames,gameStart);
- }
- else
- {
- KJC_enterframe.moveToFrame(_loc3_,_loc3_.totalFrames,gameReStart);
- }
- }
-
- private function addTimFn(param1:Event) : void
- {
- ++cTim;
- this.ScoreBox.setTim(cTim,mTim);
- if(cTim >= mTim)
- {
- gameOver();
- }
- }
-
- private function levelUpFn() : void
- {
- gamePause();
- setScore(5000);
- var _loc1_:LevelUp = new LevelUp();
- this.addChild(_loc1_);
- }
-
- internal function gameOver() : void
- {
- var _loc1_:GameOver = null;
- gamePause();
- --life;
- this.ScoreBox.setLife(life);
- this.Tom.actionTom("FAIL");
- if(life == 0)
- {
- SoundMixer.stopAll();
- _loc1_ = new GameOver(score);
- this.addChild(_loc1_);
- }
- else
- {
- gameReady(null,false);
- }
- }
- }
- }
-